package cn.gs.global.common.timer;

// @author gs
import cn.gs.exchanger.ExchangerClient.IService;
import cn.gs.exchanger.ExchangerException;
import cn.gs.exchanger.java.JavaExchangerClient;
import java.util.Arrays;
import java.util.List;

public class TimerClientTool {

    public static final String FIND_COMMAND = "gs.timer.find";
    public static final String TIMER_INSANCE = "gs.timer";

    public static void register(JavaExchangerClient client, ITimerListener listener, String clientId) throws ExchangerException {
        Process p = new Process();
        p.clientId = Arrays.asList(clientId);
        client.register(FIND_COMMAND, p, false);
        client.register(listener, ITimerListener.class, TIMER_INSANCE, clientId);
    }

    static class Process implements IService {

        List<String> clientId;

        @Override
        public List<String> process(List<String> args) throws ExchangerException {
            return clientId;
        }
    }
}
